package net.zjitc.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * Created by Administrator on 2017/9/25.
 */
@WebServlet(name = "HttpServletOne",urlPatterns ="/hservlet" )
public class HttpServletOne extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //设置响应的编码方式
        //response.setCharacterEncoding("utf-8");
        //设置响应头,给浏览器用的(设置浏览器的编码方式)
        //response.setHeader("content-type","text/html;charset=utf-8");
        //内部其实是两个部分(上面这两句和成一句)
        response.setContentType("text/html;charset=utf-8");
        /*response.setHeader("refresh","3");*/
        //response.sendRedirect("/web/gServlet");
        //重定向到登入页面??
        response.sendRedirect("/web/login/login.jsp");

        PrintWriter out =response.getWriter();
        out.write("http get ....");
        out.write("我要当会长");

    }
}
